/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package sputty.classes;

import java.io.InputStream;
import java.io.OutputStream;

/**
 *
 * @author mauro
 */
public class SendCommands extends Thread{
    
    InputStream in;
    OutputStream out;
    String[] Commands;
    int Timeout;
    boolean withCR;
    public SendCommands(InputStream in, OutputStream out, String[] Commands, int Timeout, boolean withCR){
        this.in = in;
        this.out = out;
        this.Commands = Commands;
        this.Timeout = Timeout;
        this.withCR = withCR;
    }
    
    public void run(){
        try{
            for(int i = 0;i<Commands.length;i++){
                if(withCR){
                    Commands[i] = Commands[i] + "\n";
                }
                for(int k = 0;k<Commands[i].length();k++){
                    out.write(Commands[i].codePointAt(k));
                    //System.out.print(Commands[i].charAt(k));
                }
                sleep(Timeout);
            }
        }catch(Exception e){
            e.printStackTrace();
        }
    }
    
}
